/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package citas.servlet.cita;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import trastienda.dao.CitaDAO;
import trastienda.excepcion.DAOExcepcion;
import trastienda.modelo.Cita;


public class CitaInsertarServlet extends javax.servlet.http.HttpServlet
        implements javax.servlet.Servlet {

    static final long serialVersionUID = 1L;

    
    public CitaInsertarServlet() {
        super();
    }

    
    protected void doGet(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
    }

    
    protected void doPost(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
        //
        String a = request.getParameter("idcita");


        String f = request.getParameter("pabell");
        String g = request.getParameter("est");
        String h = request.getParameter("doc");
        String i = request.getParameter("fech");
        String j = request.getParameter("hora");
        String k = request.getParameter("motivo");

        Cita vo = new Cita();

        vo.setIdcita(a);


        vo.setPabell(f);
        vo.setEst(g);
        vo.setDoc(h);
        vo.setFech(i);
        vo.setHora(j);
        vo.setMotivo(k);

        CitaDAO dao = new CitaDAO();
        try {
            dao.insertar(vo);
            RequestDispatcher rd = request.getRequestDispatcher("/hcita.jsp");
            rd.forward(request, response);
        } catch (DAOExcepcion e1) {
            System.err.println("Error");
            RequestDispatcher rd = request.getRequestDispatcher("/error.jsp");
            rd.forward(request, response);
        }

    }
}


